home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 33 / Amiga Format AFCD33 (Issue 117, Dec 1998).iso / -seriously_amiga- / programming / e / kyz_obj / test / rexxtest.e < prev   
Text File  |  1998-09-14  |  2KB  |  68 lines

  1. OPT OSVERSION=37,PREPROCESS
  2.  
  3. MODULE 'tools/easygui', 'plugins/ticker', '*rexxstate'
  4.  
  5. DEF rxs=NIL:PTR TO rexxstate, tick=NIL:PTR TO ticker,
  6.     or, os, ot, oc, tg, cg
  7.  
  8.  
  9. PROC main() HANDLE
  10.   NEW rxs.new()
  11.   easygui_fallbackA('ARexx state', gui(), [EG_WTYPE, WTYPE_NOSIZE, 0])
  12. EXCEPT DO
  13.   END tick
  14.   END rxs
  15. ENDPROC
  16.  
  17. #define RUNNING_NAME IF or := rxs.running() THEN \
  18.   '_Shutdown ARexx' ELSE '_Start ARexx'
  19. #define SUSPEND_NAME IF os := rxs.suspended() THEN \
  20.   'Res_ume ARexx programs' ELSE 'S_uspend ARexx programs'
  21.  
  22. PROC gui() IS [EQROWS,
  23.   [BUTTON, {running}, RUNNING_NAME,        0, "s"],
  24.   [BUTTON, {suspend}, SUSPEND_NAME,        0, "u"],
  25.   [BUTTON, {halt}, '_Halt Arexx programs', 0, "h"],
  26.   [PLUGIN, {update}, NEW tick],
  27.  
  28.   [BAR],
  29.  
  30. tg := [CHECK, {trace}, '_Trace mode',    ot := rxs.tracing(),      0, 0, "t"],
  31. cg := [CHECK, {cons},  'Trace _console', oc := rxs.console_open(), 0, 0, "c"]
  32. ]
  33.  
  34.  
  35. -> action procedures
  36.  
  37. PROC update(gh, x)
  38.   -> called 10 times a second (when the window is activated) by the ticker
  39.   -> this will update the GUI if someone else changes the state of ARexx,
  40.   -> with another command or such.
  41.   -> the old states (or, os, ot & oc) are updated when calling gui()
  42.   IF (rxs.running() <> or) OR (rxs.suspended() <> os) OR
  43.   (rxs.tracing() <> ot) OR (rxs.console_open() <> oc) THEN
  44.     changegui(gh, gui())
  45. ENDPROC
  46.  
  47. PROC running(gh)
  48.   IF rxs.running() THEN rxs.shutdown() ELSE rxs.start()
  49.   update(gh, 0) -> will need to redraw GUI if button name changed
  50. ENDPROC
  51.  
  52. PROC suspend(gh)
  53.   IF rxs.suspended() THEN rxs.resume() ELSE rxs.suspend()
  54.   update(gh, 0) -> will need to redraw GUI if button name changed
  55. ENDPROC
  56.  
  57. PROC halt() IS rxs.halt()
  58.  
  59. PROC trace(gh)
  60.   IF rxs.tracing() THEN rxs.trace_off() ELSE rxs.trace_on()
  61.   setcheck(gh, tg, ot := rxs.tracing())
  62. ENDPROC
  63.  
  64. PROC cons(gh)
  65.   IF rxs.console_open() THEN rxs.close_console() ELSE rxs.open_console()
  66.   setcheck(gh, tg, oc := rxs.console_open())
  67. ENDPROC
  68.